#include "config.h"
#include "fonts_manager.h"
#include<stdio.h>
#include<string.h>

static PT_FontOpr g_ptFontOprHead;

int RegisterFontOpr(PT_FontOpr ptFontOpr)
{
    PT_FontOpr ptTmp;

    if (!g_ptFontOprHead)
    {
        g_ptFontOprHead = ptFontOpr;
        ptFontOpr->ptNext = NULL;
    }
    else
    {
        ptTmp = g_ptFontOprHead;
        while (ptTmp->ptNext)
        {
            ptTmp = ptTmp->ptNext;
        }
        ptTmp->ptNext = ptFontOpr;
        ptFontOpr->ptNext = NULL;
    }
    return 0;
}
int FontsInit(void)
{
    int ret;
    ret = ASCIIInit();
    if (ret)
    {
        DBG_PRINTF("ASCIIInit error!\n");
        return -1;
    }

    ret = GBKInit();
    if (ret)
    {
        DBG_PRINTF("GBKInit error!\n");
        return -1;
    }

    ret = FreeTypeInit();
    if (ret)
    {
        DBG_PRINTF("FreeTypeInit error!\n");
        return -1;
    }

    return 0;
}
void ShowFontOpr(void)
{
    int i = 0;
    PT_FontOpr ptTmp = g_ptFontOprHead;

    while (ptTmp)
    {
        printf("%02d %s\n", i++, ptTmp->name);
        ptTmp = ptTmp->ptNext;
    }
}

PT_FontOpr GetFontOpr(char *pcName)
{
     PT_FontOpr ptTmp = g_ptFontOprHead;
     while(ptTmp)
     {
        if (strcmp(ptTmp->name, pcName) == 0)
		{
			return ptTmp;
		}
		ptTmp = ptTmp->ptNext;
     }
     return NULL;
}